package com.settlement.system.controller;

import com.settlement.system.common.util.common.RedisUtil;
import com.settlement.system.common.util.common.SystemUserUtil;
import com.settlement.system.model.entity.common.SystemUser;
import com.settlement.system.reply.ObjectDataResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 菜单记忆功能 前端控制器
 *
 * @author xiaochuan
 * @since 2020-04-13
 */

@RestController
@Slf4j
@RequestMapping("/memeory")
@Api(tags = "菜单记忆功能", description = "菜单记忆功能")
public class MemoryController {

    @GetMapping("/menu")
    @ApiOperation("菜单记忆功能")
    @ResponseBody
    public ObjectDataResponse selectBrandWithBrandUnit(HttpServletRequest req, String menuNo) {
        SystemUser systemUser = SystemUserUtil.getSystemUser();
        String jsonStr = null;
        if (systemUser != null && !StringUtils.isEmpty(systemUser.getLoginName()) && !StringUtils.isEmpty(menuNo)) {
            jsonStr = (String) RedisUtil.hget(systemUser.getLoginName(), menuNo);
        }
        return new ObjectDataResponse<String>(jsonStr);
    }
}

